﻿using System;
using System.Text;

public class ConvertNumberToText
{
    public static StringBuilder pronunciation = new StringBuilder();

    public static void Main()
    {
        int number;
        int digit;

        do
        {
            do
            {
                Console.Clear();
                Console.Write("number = ");
                if (int.TryParse(Console.ReadLine(), out number) && (0 <= number) && (number <= 999))
                    break;
            } while (true);

            Console.WriteLine("------------");
            Console.Write("{0} {1} ", number, (char)26);

            digit = number / 100;
            if (digit > 0)
            {
                Say(digit);
                pronunciation.Append(" hundred");            
                number -= digit * 100;
                if (number > 0)
                    pronunciation.Append(" and ");
            }

            digit = number / 10;
            number -= digit * 10;

            if (digit > 0)
            {
                if ((digit == 1) || (number == 0))
                    Say(digit * 10 + number);
                else
                {
                    Say(digit * 10);
                    pronunciation.Append("-");
                    Say(number);
                }
            }
            else
            {
                if (number > 0)
                    Say(number);
                else
                    if (pronunciation.Length == 0)
                        pronunciation.Append("zero");
            }

            pronunciation[0] = char.ToUpper(pronunciation[0]);
            Console.WriteLine("\"{0}\"", pronunciation.ToString());
            pronunciation.Clear();
            System.Threading.Thread.Sleep(3000);
        } while (true);
    }

    public static void Say(int n)
    {
        switch (n)
        {
            case 1: { pronunciation.Append("one"); break; }
            case 2: { pronunciation.Append("two"); break; }
            case 3: { pronunciation.Append("three"); break; }
            case 4: { pronunciation.Append("four"); break; }
            case 5: { pronunciation.Append("five"); break; }
            case 6: { pronunciation.Append("six"); break; }
            case 7: { pronunciation.Append("seven"); break; }
            case 8: { pronunciation.Append("eight"); break; }
            case 9: { pronunciation.Append("nine"); break; }
            case 10: { pronunciation.Append("ten"); break; }
            case 11: { pronunciation.Append("eleven"); break; }
            case 12: { pronunciation.Append("twelve"); break; }
            case 13: { pronunciation.Append("thirteen"); break; }
            case 14: { pronunciation.Append("fourteen"); break; }
            case 15: { pronunciation.Append("fifteen"); break; }
            case 16: { pronunciation.Append("sixteen"); break; }
            case 17: { pronunciation.Append("seventeen"); break; }
            case 18: { pronunciation.Append("eighteen"); break; }
            case 19: { pronunciation.Append("nineteen"); break; }
            case 20: { pronunciation.Append("twenty"); break; }
            case 30: { pronunciation.Append("thirty"); break; }
            case 40: { pronunciation.Append("forty"); break; }
            case 50: { pronunciation.Append("fifty"); break; }
            case 60: { pronunciation.Append("sixty"); break; }
            case 70: { pronunciation.Append("seventy"); break; }
            case 80: { pronunciation.Append("eighty"); break; }
            case 90: { pronunciation.Append("ninety"); break; }
            default: break;
        }
    }
}